from datetime import timedelta

import logging
from redis import StrictRedis


class Config(object):
    # 调试信息
    DEBUG = True
    SECRET_KEY = "dfdfddffddfff"

    # 数据库配置信息
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root123456@localhost:3306/info36"
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # redis配置信息
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # session配置信息
    SESSION_TYPE = "redis"  # 设置session存储类型
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    SESSION_USE_SIGNER = True  # 设置签名存储
    PERMANENT_SESSION_LIFETIME = timedelta(days=5)  # 设置session有效期

    # 默认日记级别
    LEVEL_NAME = logging.DEBUG


# 开发环境配置信息
class DevelopConfig(Config):
    pass


# 生产环境配置信息
class ProductConfig(Config):
    DEBUG = False
    LEVEL_NAME = logging.ERROR


# 测试环境配置信息
class TestConfig(Config):
    pass


# 提供统一的访问入口
config_dict = {
    "develop": DevelopConfig,
    "pruduct": ProductConfig,
    "test": TestConfig
}
